<%--
  Created by IntelliJ IDEA.
  User: RuoLi
  Date: 2022/12/14
  Time: 21:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>忘记密码</title>
    <script src="<%=request.getContextPath()%>/js/jquery.js"></script>
    <script src="<%=request.getContextPath()%>/js/agree.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/base.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/iconfont.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/reg.css">
</head>
<body>
<%--    <div>--%>
<%--        <form method="post" action="User/UserForgetPassword">--%>
<%--            <div>账号<input type="text" id="UserAccount" name="UserAccount"></div>--%>
<%--            <div>邮箱<input type="email" id="UserMail" name="UserMail"></div>--%>
<%--            <div><input type="button" id="forgetPwdSubmit" value="提交"></div>--%>
<%--        </form>--%>
<%--    </div>--%>
<%--    <div>--%>
<%--        <p>发送到用户邮箱，密码更改为随机密码</p>--%>
<%--    </div>--%>

<div id="ajax-hook"></div>
<div class="wrap">
    <div class="wpn">
        <div class="form-data find_password">
            <h4>找回密码</h4>
            <p class="right_now">已有账号，<a href="./index.jsp">马上登录</a></p>
            <p class="p-input pos">
                <label for="UserMail">邮箱</label>
                <input type="text" id="UserMail">
            </p>
            <p class="p-input pos">
                <label for="UserAccount">账号</label>
                <input type="text" id="UserAccount">
            </p>
            <button class="lang-btn next">提交</button>
        </div>
    </div>
</div>

</body>
<script type="text/javascript">
    $(".next").click(function () {
        if ($("#UserAccount").val().length < 5 && $("#UserMail").val().length < 10) {
            alert("输入长度不规范")
        }else {
            $.ajax({
                type: "post",
                url: "User/UserForgetPassword",
                data: {
                    UserMail: $("#UserMail").val(),
                    UserAccount: $("#UserAccount").val()
                },
                success: function (data) {
                    if (parseInt(data)===0){
                        alert("当前账号不存在请重新输入")
                    }else {
                        alert("提交成功，请在邮箱查收")
                        window.location.href = "index.jsp";
                    }
                },
                error: function () {
                    alert("发送失败，系统发送错误")
                }
            })
        }
    })
</script>
</html>